package com.chief.sink.elasticsearch;


import com.alibaba.fastjson.JSONObject;
import org.apache.flink.api.common.functions.MapFunction;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

public class EsTest {
    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

        DataStreamSource<JSONObject> dataStreamSource = env.addSource(new EsSource(), "es source");

        SingleOutputStreamOperator<JSONObject> map = dataStreamSource.map(new MapFunction<JSONObject, JSONObject>() {
            @Override
            public JSONObject map(JSONObject jsonObject) throws Exception {
                return jsonObject;
            }
        });
        map.print("map");

        map.addSink(new EsSink());

        env.execute("es test3");
    }
}
